import 'package:getx_demo/pages/alive/index.dart';
import 'package:getx_demo/pages/home/index.dart';
import 'package:getx_demo/pages/mine/index.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';

class MaintabPage extends GetView<MaintabController> {
  const MaintabPage({Key? key}) : super(key: key);

  final _pageList = const [HomePage(), AlivePage(), MinePage()];

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MaintabController>(
      init: MaintabController(),
      id: "maintab",
      builder: (_) {
        return Scaffold(
          // appBar: AppBar(title: const Text("maintab")),
          bottomNavigationBar: BottomNavigationBar(
            items: const [
              BottomNavigationBarItem(
                icon: Icon(Icons.home),
                label: '首页',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.add),
                label: 'Alive',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.settings),
                label: '我的',
              )
            ],
            currentIndex: controller.currentIndex,
            onTap: controller.changeItem,
            type: BottomNavigationBarType.fixed,
          ),
          body: PageView(
            controller: controller.pageController,
            children: _pageList,
          ),
          // _pageList[controller.currentIndex],
        );
      },
    );
  }
}
